# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=pkgfile
pkgver=15
pkgrel=1
pkgdesc="A pacman .files metadata explorer"
arch=('i686' 'x86_64')
url="http://github.com/falconindy/pkgfile"
groups=('base' 'base-devel')
license=('MIT')
depends=('libarchive' 'curl' 'pcre' 'pacman')
options=('emptydirs')
source=("http://code.falconindy.com/archive/$pkgname/$pkgname-$pkgver.tar.xz"{,.sig})
install=pkgfile.install
md5sums=('30b3c4f0b18a33ca0ce4538492093511'
         'SKIP')

prepare() {
  cd "$srcdir/$pkgname-$pkgver"
}

build() {
  [[ -d "$srcdir/build-${CHOST}" ]] && rm -rf "$srcdir/build-${CHOST}"
  mkdir "$srcdir/build-${CHOST}" && cd "$srcdir/build-${CHOST}"
  #cd "$pkgname-$pkgver"

  ../$pkgname-$pkgver/configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var
  make

  # generate a license file
  sed '/\*\//q' $srcdir/$pkgname-$pkgver/src/pkgfile.c >LICENSE
}

package() {
  cd "$srcdir/build-${CHOST}"

  make DESTDIR="$pkgdir" install
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
